package com.lry;

import com.lry.config.BrokerConfig;
import com.lry.config.FlushDiskType;
import com.lry.config.MessageStoreConfig;
import com.lry.rpc.MqRpcServiceImpl;
import com.lry.server.RpcServer;


public class BrokerStartup {

    public static void main(String[] args) throws Exception {

        BrokerConfig brokerConfig = new BrokerConfig();

        BrokerController brokerController = new BrokerController(brokerConfig,buildMessageStoreConfig());

        RpcServer rpcServer = new RpcServer(brokerConfig.getHost(),brokerConfig.getPort());

        rpcServer.registerService(new MqRpcServiceImpl(brokerController));

        rpcServer.start();

    }

    //测试使用
    private static MessageStoreConfig buildMessageStoreConfig()   {
        MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
        messageStoreConfig.setMappedFileSizeCommitLog(1024 * 1024 * 10);
        messageStoreConfig.setMappedFileSizeConsumeQueue(1024 * 1024 * 10);
        messageStoreConfig.setMaxHashSlotNum(10000);
        messageStoreConfig.setMaxIndexNum(100 * 100);
        messageStoreConfig.setFlushDiskType(FlushDiskType.SYNC_FLUSH);
        messageStoreConfig.setFlushIntervalConsumeQueue(1);

        return messageStoreConfig;
    }

}
